import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:Tcp版本的字典服务器
 * Author: WJW
 * Date: 2024-08-25
 * Time: 16:04
 */
public class TcpDickServer extends TcpEchoServer{
    private HashMap<String,String> hashMap = new HashMap<>();

    public TcpDickServer(int port) throws IOException {
        super(port);
        hashMap.put("cat","小猫");
        hashMap.put("dog","小狗");
        hashMap.put("hello","你好");
        hashMap.put("book","书本");
    }

    @Override
    public String process(String request){
        return hashMap.getOrDefault(request,"您要查找的单词不存在！");
    }

    public static void main(String[] args) throws IOException {
        TcpDickServer server = new TcpDickServer(9090);
        server.start();
    }

}
